package com.wdl.ad.function

import com.wdl.ad.bean.AdCountByProvince
import org.apache.flink.streaming.api.scala.function.WindowFunction
import org.apache.flink.streaming.api.windowing.windows.TimeWindow
import org.apache.flink.util.Collector

import java.sql.Timestamp

class AdCountResult extends WindowFunction[Long, AdCountByProvince, String, TimeWindow]{
  override def apply(key: String, window: TimeWindow, input: Iterable[Long], out: Collector[AdCountByProvince]): Unit = {
    out.collect(
      AdCountByProvince(key,
        new Timestamp(window.getEnd).toString,
        input.head))
  }
}
